﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShiXuLong.Service;
namespace ShiXuLong.Web.Controllers
{

    public class HomeController : Controller
    {
        ShoesService shoes = new ShoesService();
        FrontDesk methods = new FrontDesk();
        // GET: Home
        /// <summary>
        /// 主页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {

            ViewBag.Type = methods.GetShopType();
            return View();
        }
        /// <summary>
        /// 商品列表页
        /// </summary>
        /// <returns></returns>
        public ActionResult Shoes(string ShopName)
        {
            var list = shoes.GetShoess(ShopName);
            ViewBag.AdminUrl = MyConfig.AdminUrl;
            return View(list);
        }
        /// <summary>
        /// 商品详情
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public ActionResult ShoesDetails(int ShopId=2)
        {
            ViewBag.AdminUrl = MyConfig.AdminUrl;
            var list = shoes.GetShoes(ShopId);
            return View(list);
        }

        /// <summary>
        /// 测试页面
        /// </summary>
        /// <returns></returns>
        public ActionResult TestView()
        {
            return View();
        }
        /// <summary>
        /// 购物车主页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Cart()
        {
            var list = methods.GetCart();
            return View(list);
        }
        public ActionResult AddCart(int id)
        {
            var res = shoes.AddCart(id);
            if (res > 0)
            {
                return Json(new { success = true, msg = "执行成功" });
            }
            else
            {
                return Json(new { success = false, msg = "执行失败" });
            }
        }

        public ActionResult SignIn()
        {

            return View();
        }
    }
}